﻿//datepicker
jQuery(function ($) {
    $("#MainContent_txt密码有效期").datepicker();
});

//autocomplete 所属区分
jQuery(function ($) {
    var tmp_data_所属区分;

    $("#MainContent_txt所属区分CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH004.ashx",
                dataType: "json",
                data: { "KEY1": $("#MainContent_txt所属区分CD").val() },
                success: function (data) {
                    tmp_data_所属区分 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEY1 + "\t" + item.CODE1_HANZI,
                            value: item.KEY1,
                            CODE1_HANZI: item.CODE1_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt所属区分").html(ui.item.CODE1_HANZI);
            $("#MainContent_hid所属区分").val($("#MainContent_txt所属区分").html());
        }
    });

    $("#MainContent_txt所属区分CD").focusout(function () {
        if (tmp_data_所属区分 != null) $("#MainContent_txt所属区分").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_所属区分, function (i, v) {
            if (v.KEY1 == $("#MainContent_txt所属区分CD").val()) {
                $("#MainContent_txt所属区分").html(v.CODE1_HANZI);
                $("#MainContent_hid所属区分").val($("#MainContent_txt所属区分").html());
                return;
            }
        });

    });
});

//autocomplete 部门
jQuery(function ($) {
    var tmp_data_部门;

    $("#MainContent_txt部门CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH005.ashx",
                dataType: "json",
                data: { "KEY1": $("#MainContent_txt部门CD").val() },
                success: function (data) {
                    tmp_data_部门 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEY1 + "\t" + item.CODE1_HANZI,
                            value: item.KEY1,
                            CODE1_HANZI: item.CODE1_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt部门").html(ui.item.CODE1_HANZI);
            $("#MainContent_hid部门").val($("#MainContent_txt部门").html());
        }
    });

    $("#MainContent_txt部门CD").focusout(function () {
        if (tmp_data_部门 != null) $("#MainContent_txt部门").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_部门, function (i, v) {
            if (v.KEY1 == $("#MainContent_txt部门CD").val()) {
                $("#MainContent_txt部门").html(v.CODE1_HANZI);
                $("#MainContent_hid部门").val($("#MainContent_txt部门").html());
                return;
            }
        });

    });
});

//autocomplete 职位
jQuery(function ($) {
    var tmp_data_职位;

    $("#MainContent_txt职位CD").autocomplete({
        delay: 100,
        minLength: 1,
        source: function (request, response) {
            $.ajax({
                url: "./common/ASH006.ashx",
                dataType: "json",
                data: { "KEY1": $("#MainContent_txt职位CD").val() },
                success: function (data) {
                    tmp_data_职位 = data;
                    response($.map(data, function (item) {
                        return {
                            label: item.KEY1 + "\t" + item.CODE1_HANZI,
                            value: item.KEY1,
                            CODE1_HANZI: item.CODE1_HANZI
                        }
                    }));
                }
            });
        },
        select: function (e, ui) {
            $("#MainContent_txt职位").html(ui.item.CODE1_HANZI);
            $("#MainContent_hid职位").val($("#MainContent_txt职位").html());
        }
    });

    $("#MainContent_txt职位CD").focusout(function () {
        if (tmp_data_职位 != null) $("#MainContent_txt职位").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        //
        $.each(tmp_data_职位, function (i, v) {
            if (v.KEY1 == $("#MainContent_txt职位CD").val()) {
                $("#MainContent_txt职位").html(v.CODE1_HANZI);
                $("#MainContent_hid职位").val($("#MainContent_txt职位").html());
                return;
            }
        });

    });
});
